import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);

Vue.use(VueRouter);
const routes = [
  {
    path: '/',
    name: "home",
    component: () => import("@/components/index/Home.vue"),
    meta: {
      title: "首页"
    }
  },
  {
    path: '/users',
    name: "user",
    component: () => import("@/views/UserManage.vue"),
    meta: {
      title: "用户管理"
    }
  },
  {
    path: '/fm',
    name: 'fm',
    component: () => import("@/views/comtent/FmManager.vue"),
    meta: {
      title: "fm管理"
    }
  },
  {
    path: '/course',
    name: 'course',
    component: () => import("@/views/course/CourseComponent"),
    meta: {
      title: "课程管理"
    }
  },

  {
    path:'/company',
    name:'company',
    component:() => import("@/views/company/CompanyContent"),
    meta:{
      title:"公司管理"
    }
  },
  {
    path: "/article",
    name: "article",
    component: () => import("@/views/comtent/ArticleManager.vue"),
    meta: {
      title: "文章管理",
    },
  },
  {
    path: "/question",
    name: "question",
    component: () => import("@/views/comtent/QuestionMannager.vue"),
    meta: {
      title: "答疑管理",
    }, 
  },
  {
    path: "/pubwel",
    name: "pubwel",
    component: () => import("@/views/comtent/PublicityManager.vue"),
    meta: {
      title: "公益管理",
    },
  },
  {
    path: "/notice",
    name: "notice",
    component: () => import("@/views/comtent/MyNoticeManager.vue"),
    meta: {
      title: "公告管理",
    },
  },{
    path: '/heartKnowledge',
    name: 'heartKnowledge',
    component: () => import("@/views/heartKnowledge/heartKnowledgeComponent"),
    meta: {
      title: "心理知识管理"
    }
  },
  {
    path: '/heartmark',
    name: 'heartmark',
    component: () => import("@/views/course/HeartMarkComponent.vue"),
    meta: {
      title: "心理测评管理"
    }
  },
  {
    path: '/home',
    name: "home",
    component: () => import("@/components/index/Home.vue"),
    meta: {
      title: "首页"
    }
  },
  {
    path: '/UserManagement',
    name: 'UserManagement',
    component: () => import("@/views/usermanagement/UserManagement"),
    meta: {
      title: "用户管理"
    }
  },

  {
    path: '/reservation',
    name: 'reservation',
    component: () => import("@/views/WReservation/WReservation.vue"),
    meta: {
      title: "咨询管理"
    }
  }
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// 添加全局前置守卫
router.beforeEach((to, from, next) => {
  if (to.path === from.path) {
    next(false); // 阻止重复导航
  } else {
    next(); // 继续导航
  }
});


export default router

